namespace ACRSAP.Administration.UserControls
{
    using System;
    using System.Collections;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class AdminTabs : UserControl
    {
        [AccessedThroughProperty("lstTabs")]
        private DataList _lstTabs;
        public string CurrentTabName;
        private object designerPlaceholderDeclaration;

        public AdminTabs()
        {
            base.Load += new EventHandler(this.Page_Load);
            base.Init += new EventHandler(this.Page_Init);
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
        }

        public void lstTabs_ItemDataBound(object s, DataListItemEventArgs e)
        {
            AdminTab objTab = (AdminTab) e.Item.DataItem;
            HyperLink lnkTab = (HyperLink) e.Item.FindControl("lnkTab");
            lnkTab.Text = objTab.Name;
            lnkTab.NavigateUrl = objTab.Url;
            if (string.Compare(this.CurrentTabName, objTab.Name) == 0)
            {
                e.Item.CssClass = "adminTabActive";
            }
            else
            {
                e.Item.CssClass = "adminTabInactive";
            }
        }

        private void Page_Init(object sender, EventArgs e)
        {
            this.InitializeComponent();
        }

        private void Page_Load(object sender, EventArgs e)
        {
            ArrayList colTabs = new ArrayList();
            colTabs.Add(new AdminTab("Projects", "~/Administration/Projects/ProjectList.aspx"));
            colTabs.Add(new AdminTab("Users", "~/Administration/Users/UserList.aspx"));
            this.lstTabs.DataSource = colTabs;
            this.lstTabs.DataBind();
        }

        protected virtual DataList lstTabs
        {
            get
            {
                return this._lstTabs;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._lstTabs != null)
                {
                    this._lstTabs.ItemDataBound -= new DataListItemEventHandler(this.lstTabs_ItemDataBound);
                }
                this._lstTabs = value;
                if (this._lstTabs != null)
                {
                    this._lstTabs.ItemDataBound += new DataListItemEventHandler(this.lstTabs_ItemDataBound);
                }
            }
        }

        public class AdminTab
        {
            public string Name = string.Empty;
            public string Url = string.Empty;

            public AdminTab(string name, string url)
            {
                this.Name = name;
                this.Url = url;
            }
        }
    }
}

